// 搜索框
class Opt {
    constructor(newbox) {
        this.box = newbox;
    }
    setshow() {
        this.box.style.display = "block";
    }
    sethide() {
        this.box.style.display = "none";
    }
}

let oin = document.querySelector("input");
let opt = document.querySelector(".opt");
let o = new Opt(opt);
oin.onclick = function(evt) {
    let e = evt || event;
    e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
    o.setshow();
}
document.onclick = function() {
        o.sethide();
    }
//-----------------------------------------
// 购物车弹出框
$("#header-top .top li:first-child").mouseover(function() {
    $(".pop").slideDown();
});
$(document).click(function() {
    $(".pop").slideUp();
});

// 点击进入详情页
$(".go").click(function(){
	location.href="Page.html";
});

//----------------------------------------------
// 二级导航
// 男装
$("#header-center .center .man").hover(function() {
    $("#gentle").stop().slideDown();
}, function() {
    $("#gentle").stop().slideUp();
});

// 女装
$("#header-center .center .woman").hover(function() {
    $("#lady").stop().slideDown();
}, function() {
    $("#lady").stop().slideUp();
});

// 头部吸顶


window.onscroll = function() {
    let off = document.querySelector("#header-center");
    let len = off.offsetTop;
    let scrol = document.documentElement.scrollTop;
    if (scrol > len) {
        off.style.position = "fixed";
        off.style.top = 0;
        off.style.zIndex = 999;
        $("#onelogo img").css({
            width: 100,
            height: 50,
            top: 3
        });
        $(".opt").css({
            top: 50
        });
    } else {
        off.style.position = "sticky";
        off.style.zIndex = 9999;
        $("#onelogo img").css({
            width: 167,
            height: 96,
            top: -33
        });
        $(".opt").css({
            top: 50
        });
        $(".pop").css({
            zIndex: 99999
        });
    }
}